package com.imay.live.activity.user.util;

import android.os.CountDownTimer;
import android.os.Handler;

/**
 * 倒计时器
 * Created by chan on 2017/3/28.
 */

public class RegisterCodeTimer extends CountDownTimer {

    private static Handler mHandler;
    public static final int IN_RUNNING = 1001;
    public static int END_RUNNING = 1002;

    public RegisterCodeTimer(long millisInFuture, long countDownInterval, Handler handler) {
        super(millisInFuture, countDownInterval);
        mHandler = handler;
    }

    @Override
    public void onTick(long l) {
        if (mHandler != null)
            mHandler.obtainMessage(IN_RUNNING,
                    (l / 1000) + "s").sendToTarget();

    }

    @Override
    public void onFinish() {
        if (mHandler != null)
            mHandler.obtainMessage(END_RUNNING, "END").sendToTarget();
    }
}
